package org.example.aop;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AopAspect {

    @Before("execution(* org.example.util..*(..))")
    public void logMethod(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        System.out.println("打印参数");
        for (Object arg : args) {
            System.out.println(arg);
            String jsonStr = JSONUtil.toJsonStr(arg);
            System.out.println(jsonStr);
        }
    }


    @AfterReturning(pointcut = "execution(* org.example.util..*(..))",returning = "result")
    public void printReturn(JoinPoint joinPoint,Object result){
        System.out.println(JSONUtil.toJsonStr(result));
    }
//rebase测试
//rebase second
//rebase third
}
